package com.yanqu.road.server.cmd.rank;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.rank.RankProto;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.config.BeautyMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = GameProtocol.S_GET_BEAUTY_RANK_DETAIL_INFO, desc = "获取美女排行美女详细信息")
public class GetBeautyRankDetailInfoCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

        RankProto.GetBeautyRankDetailInfoReqMsg reqMsg = RankProto.GetBeautyRankDetailInfoReqMsg.parseFrom(packet.getBytes());
        if (reqMsg.getServerId() == GameServer.getInstance().getServerId()) { //同服
            String detailInfoJsonStr = BeautyMgr.getUserBeautyDetailInfoJsonStr(reqMsg.getUserId(), reqMsg.getId());
            RankProto.GetBeautyRankDetailInfoRespMsg.Builder respMsg = RankProto.GetBeautyRankDetailInfoRespMsg.newBuilder();
            respMsg.setInfoJsonStr(detailInfoJsonStr);
            player.sendPacket(Protocol.U_GET_BEAUTY_RANK_DETAIL_INFO, respMsg);
        } else { //跨服
            YanQuMessage message = YanQuMessageUtils.buildMessage(Protocol.C_GET_BEAUTY_RANK_DETAIL_INFO, reqMsg.toBuilder());
            GamePlayerMgr.sendPacket(player, message);
        }

    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
